from scrapy.crawler import CrawlerProcess
from scrapy.utils.project import get_project_settings
from image_spider.spiders.one_piece_spider import OnePieceImageSpider

if __name__ == "__main__":
    # 加载项目设置
    settings = get_project_settings()

    # 可以在这里修改或添加额外的设置
    # settings['LOG_LEVEL'] = 'DEBUG'
    # settings['DOWNLOAD_DELAY'] = 2

    # 创建爬虫进程
    process = CrawlerProcess(settings)

    # 添加并启动爬虫
    process.crawl(OnePieceImageSpider)
    process.start()  # 执行爬虫，阻塞直到完成